<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="###Jcenter 依赖完整版 测试环境： github仓库(码云仓库无法依赖)、Jcenter仓库、Android Studio2.2.2、Gradle 2.14.1、TortoiseSVN 1.9.6。  在github上注册账号并创建项目(其具体创建方法自行查阅), 使用SVN克隆代码，在克隆时SVN需要设置代理，设置代理方法桌面右键-&amp;gt;TortoiseSVN-&amp;gt;Setting">
<meta name="keywords" content="Android、iOS、Web、React Native">
<meta property="og:type" content="article">
<meta property="og:title" content="Android-Jcenter-依赖完整版">
<meta property="og:url" content="http://yoursite.com/blog/2018/08/06/Android-Special-Function/Android-Jcenter-依赖完整版/index.html">
<meta property="og:site_name" content="凌浩雨_博客">
<meta property="og:description" content="###Jcenter 依赖完整版 测试环境： github仓库(码云仓库无法依赖)、Jcenter仓库、Android Studio2.2.2、Gradle 2.14.1、TortoiseSVN 1.9.6。  在github上注册账号并创建项目(其具体创建方法自行查阅), 使用SVN克隆代码，在克隆时SVN需要设置代理，设置代理方法桌面右键-&amp;gt;TortoiseSVN-&amp;gt;Setting">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-9f4ee4488ce2b40c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-13adad0d79f01a87.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-d7d2c2fd496a13a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-c1ad4ac8a8a911e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-aeb2731bdf81caf6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-d6dbd1ced0faa4e4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-00dbb1c064601aa7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-66bddeadb5062894.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-98630bc501b7fc3a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-08-06T11:08:39.882Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android-Jcenter-依赖完整版">
<meta name="twitter:description" content="###Jcenter 依赖完整版 测试环境： github仓库(码云仓库无法依赖)、Jcenter仓库、Android Studio2.2.2、Gradle 2.14.1、TortoiseSVN 1.9.6。  在github上注册账号并创建项目(其具体创建方法自行查阅), 使用SVN克隆代码，在克隆时SVN需要设置代理，设置代理方法桌面右键-&amp;gt;TortoiseSVN-&amp;gt;Setting">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/3110861-9f4ee4488ce2b40c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/blog/2018/08/06/Android-Special-Function/Android-Jcenter-依赖完整版/"/>





  <title>Android-Jcenter-依赖完整版 | 凌浩雨_博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">凌浩雨_博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/blog/blog/2018/08/06/Android-Special-Function/Android-Jcenter-依赖完整版/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="凌浩雨">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="凌浩雨_博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Android-Jcenter-依赖完整版</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-06T18:01:38+08:00">
                2018-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>###Jcenter 依赖完整版</p>
<p>测试环境： github仓库(码云仓库无法依赖)、Jcenter仓库、Android Studio2.2.2、Gradle 2.14.1、TortoiseSVN 1.9.6。</p>
<ol>
<li>在<a href="https://github.com/" target="_blank" rel="noopener">github</a>上注册账号并创建项目(其具体创建方法自行查阅), 使用SVN克隆代码，在克隆时SVN需要设置代理，设置代理方法<strong>桌面右键-&gt;TortoiseSVN-&gt;Settings-&gt;Network-&gt;勾选Enable Proxy Server, Server address填写localhost，Port(自己查阅自己使用的科学上网工具端口)</strong><a id="more"></a>
</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-9f4ee4488ce2b40c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图1.png"><br>点击应用，即可。克隆代码时使用HTTPS方式克隆，克隆完成后将自己的写好的代码添加并上传到github仓库。</p>
<ol start="2">
<li>在<a href="https://bintray.com/signup/oss" target="_blank" rel="noopener">Jcenter</a>注册并登陆</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-13adad0d79f01a87.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图2.png"></p>
<p>登陆成功后在头像位置选择Edit Profile，选择左侧的API KEY，获取到自己的API KEY。</p>
<ol start="3">
<li>在Jcenter创建仓库</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-d7d2c2fd496a13a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图3.png"><br>点击左侧All(1)下的Add New Repository，进入到新建仓库页面</p>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-c1ad4ac8a8a911e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图4.png"></p>
<p>其中Name是仓库名， Type选择Maven， Default Licenses(Optional)选择Apache-2.0，Description(Optional) 是描述信息(可不填)，选择创建。</p>
<ol start="4">
<li>进入到新建的仓库页面</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-aeb2731bdf81caf6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图5.png"><br>右侧选择Add New Package，进入新建包页面</p>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-d6dbd1ced0faa4e4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图6.png"><br>其中Name是工程名， Description是描述信息(可不写), Licenses是Apache-2.0, Maturity 选择None， Website是github上项目的主页， Issues tracker可不填，如果要写就在Website中填写的内容链接后加”/issues”, Version control是版本控制，这里填写github项目HTTPS的链接。填写好后点击创建。</p>
<ol start="5">
<li>设置Android Studio中Gradle中的文件配置。<ul>
<li>根目录下的build.gradle中加入上传开源库的依赖：<br><code>classpath &#39;com.novoda:bintray-release:0.3.4&#39;</code><br>(1.bintray-releas version 0.5.0 对应 Gradle 是 version 3.4+ (包括3.4)<br>2.bintray-releas version 0.4.0 对应 Gradle 是 version 3.3+ (包括3.3)<br>3.bintray-releas version 0.3.4 对应 Gradle 是 version 1.3.0+(包括1.3)<br>)</li>
<li>library的moudel中加入 apply<br><code>apply plugin: &#39;com.novoda.bintray-release&#39;</code></li>
</ul>
</li>
</ol>
<ul>
<li><p>如果你开源库中有中文注释在module的build.gradle加入格式</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">allprojects &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        jcenter()</span><br><span class="line">    &#125;</span><br><span class="line">    //加上这些</span><br><span class="line">    tasks.withType(Javadoc) &#123;</span><br><span class="line">        options&#123; encoding &quot;UTF-8&quot;</span><br><span class="line">            charSet &apos;UTF-8&apos;</span><br><span class="line">            links &quot;http://docs.oracle.com/javase/7/docs/api&quot;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>忽略错误信息：在项目的每一个module的build.gradle</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">android &#123;</span><br><span class="line">******</span><br><span class="line">******</span><br><span class="line"> lintOptions &#123;</span><br><span class="line">        abortOnError false</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置基本信息</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">publish &#123;</span><br><span class="line">  repoName=&quot;Test&quot;//仓库名(repoName 如果没有填写，上传的库默认仓库是maven)</span><br><span class="line">  userOrg = &apos;mazaiting&apos;      //bintray注册的用户名</span><br><span class="line">  groupId = &apos;com.mazaiting&apos;     //compile引用时的第1部分groupId</span><br><span class="line">  artifactId = &apos;popupwindow&apos;     //compile引用时的第2部分项目名</span><br><span class="line">  publishVersion = &apos;1.0.1&apos;    //compile引用时的第3部分版本号</span><br><span class="line">  desc = &apos;This is a rxbus same of eventbus extend library &apos;//d项目描述</span><br><span class="line">  website = &apos;https://github.com/mazaiting/PopupWindow&apos; //github 托管地址</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>切换到AndroidStudio temrinal或者cmd后台中运行：<br>windows系统中(其中BINTRAY_USERNAME换成bintray注册的用户名，BINTRAY_KEY换成自己的APIKEY)<br><code>gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false</code><br>回车执行命令，看到BUILD SUCCESS即上传成功</p>
</li>
</ul>
<ol start="6">
<li>此时回到自己在Jcenter新建Package的页面并刷新</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-00dbb1c064601aa7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图7.png"><br>可以看到右侧多了一个1.0.1版本的项目，此时可以在自己的项目中依赖它。</p>
<ol start="7">
<li>依赖项目<br>在项目根目录的build.gradle文件中添加仓库<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">allprojects &#123;</span><br><span class="line">  repositories &#123;</span><br><span class="line">    jcenter()</span><br><span class="line">    maven &#123;</span><br><span class="line">      url &apos;https://dl.bintray.com/mazaiting/Test&apos;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>其中maven中的链接是在项目主页的右上角，复制它即可。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-66bddeadb5062894.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图8.png"></p>
<p>在主Module中build.gradle文件下添加<br><code>compile &#39;com.mazaiting:popupwindow:1.0.1&#39;</code><br>即可依赖自己的项目。</p>
<ol start="8">
<li>发布项目到公用Jecenter中</li>
</ol>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-98630bc501b7fc3a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图9.png"><br>在右下角选择Add to JCenter，新页面直接点击send， 等待5-6个小时后审核通过后即可使用。通过后在Linked to 的下面会出现一个Jcenter的<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">allprojects &#123;</span><br><span class="line">    repositories &#123;</span><br><span class="line">        jcenter()</span><br><span class="line">         maven &#123; url &quot;https://jitpack.io&quot; &#125; //审核后可使用</span><br><span class="line">         maven &#123; url &quot;https://dl.bintray.com/mazaiting/Test&quot; &#125;//审核前可使用</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Special-Function/Android-Gradle详解/" rel="next" title="Android-Gradle详解">
                <i class="fa fa-chevron-left"></i> Android-Gradle详解
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Special-Function/Android-JNI-Windows配置/" rel="prev" title="Android-JNI-Windows配置">
                Android-JNI-Windows配置 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blog/images/avatar.jpeg"
                alt="凌浩雨" />
            
              <p class="site-author-name" itemprop="name">凌浩雨</p>
              <p class="site-description motion-element" itemprop="description">专业从事于移动端开发，Android与iOS均有涉及，主做Android开发与React Native开发</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">393</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">凌浩雨</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
